package com.linkoog.devtools.code_generator.setting.configurable.ui;

import com.linkoog.devtools.code_generator.setting.configurable.ui.variable.DefaultVariable;
import com.linkoog.devtools.code_generator.setting.configurable.ui.variable.VariableEnum;
import com.linkoog.devtools.code_generator.setting.configurable.ui.variable.VariableTreeTableModel;
import com.intellij.uiDesigner.core.GridConstraints;
import com.intellij.uiDesigner.core.GridLayoutManager;
import com.intellij.uiDesigner.core.Spacer;
import org.jdesktop.swingx.JXTreeTable;

import javax.swing.*;
import java.awt.*;

public class TemplateVariablePanel {

    private JPanel myMainPanel;

    private JXTreeTable templateVariableTreeTable;
    private JScrollPane templateVariableScrollPanel;

    public TemplateVariablePanel() {
        initVariableTreeTable();
    }

    /**
     * 模板内置参数
     */
    private void initVariableTreeTable() {
        VariableTreeTableModel variableTreeTableModel = new VariableTreeTableModel(DefaultVariable.getDefaultVariableTreeTableNode());
        templateVariableTreeTable = new JXTreeTable(variableTreeTableModel);

        templateVariableTreeTable.getColumnModel().getColumn(VariableEnum.Name.getIndex()).setPreferredWidth(110);
        templateVariableTreeTable.getColumnModel().getColumn(VariableEnum.ParamName.getIndex()).setPreferredWidth(30);
        templateVariableTreeTable.getColumnModel().getColumn(VariableEnum.ParamType.getIndex()).setPreferredWidth(20);
        templateVariableTreeTable.getColumnModel().getColumn(VariableEnum.ParamDefault.getIndex()).setPreferredWidth(20);
        templateVariableTreeTable.getColumnModel().getColumn(VariableEnum.ParamExplain.getIndex()).setPreferredWidth(350);
        templateVariableTreeTable.setRootVisible(false);
        templateVariableTreeTable.expandAll();

        templateVariableScrollPanel.getViewport().add(templateVariableTreeTable);
    }


    public JPanel getMyMainPanel() {
        return myMainPanel;
    }

    {
// GUI initializer generated by IntelliJ IDEA GUI Designer
// >>> IMPORTANT!! <<<
// DO NOT EDIT OR ADD ANY CODE HERE!
        $$$setupUI$$$();
    }

    /**
     * Method generated by IntelliJ IDEA GUI Designer
     * >>> IMPORTANT!! <<<
     * DO NOT edit this method OR call it in your code!
     *
     * @noinspection ALL
     */
    private void $$$setupUI$$$() {
        myMainPanel = new JPanel();
        myMainPanel.setLayout(new GridLayoutManager(3, 2, new Insets(0, 0, 0, 0), -1, -1));
        final JPanel panel1 = new JPanel();
        panel1.setLayout(new GridLayoutManager(1, 1, new Insets(0, 0, 0, 0), -1, -1));
        myMainPanel.add(panel1, new GridConstraints(0, 0, 1, 2, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_BOTH, GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, null, null, null, 0, false));
        final Spacer spacer1 = new Spacer();
        myMainPanel.add(spacer1, new GridConstraints(1, 1, 1, 1, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_VERTICAL, 1, GridConstraints.SIZEPOLICY_WANT_GROW, null, null, null, 0, false));
        templateVariableScrollPanel = new JScrollPane();
        myMainPanel.add(templateVariableScrollPanel, new GridConstraints(1, 0, 1, 1, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_BOTH, GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_WANT_GROW, GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_WANT_GROW, null, null, null, 0, false));
        final JPanel panel2 = new JPanel();
        panel2.setLayout(new GridLayoutManager(1, 1, new Insets(0, 0, 0, 0), -1, -1));
        myMainPanel.add(panel2, new GridConstraints(2, 0, 1, 2, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_BOTH, GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, null, null, null, 0, false));
    }

    /**
     * @noinspection ALL
     */
    public JComponent $$$getRootComponent$$$() {
        return myMainPanel;
    }
}
